package com.dream.keigezhushou.Activity.acty.personal.fragment;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ListView;


import com.dream.keigezhushou.R;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * 商品界面
 */

public class ProductFragment extends Fragment {

    @BindView(R.id.product_list)
    ListView productList;
    private View mView;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        if (mView == null) {
            mView = LayoutInflater.from(getContext()).inflate(R.layout.layout_product_fragment, container, false);
        }

        ViewGroup viewGroup = (ViewGroup) mView.getParent();
        if (viewGroup != null) {

            viewGroup.removeView(mView);
        }
        ButterKnife.bind(this, mView);

        initData();
        return mView;
    }

    //初始化数据
    protected void initData(){

        //ListView创建适配器
        productList.setAdapter(new proAdapter());
    }

    public class proAdapter extends BaseAdapter{

        int c = 6;

        public proAdapter() {
            super();
        }

        @Override
        public int getCount() {
            return c;
        }

        @Override
        public Object getItem(int i) {
            return i;
        }

        @Override
        public long getItemId(int i) {
            return i;
        }

        @Override
        public View getView(int i, View view, ViewGroup viewGroup) {

            ProHolder mHolder = null;
            if (view == null) {

                view = LayoutInflater.from(getActivity()).inflate(R.layout.product_item,null);
                mHolder = new ProHolder();
                view.setTag(mHolder);
            }else {
                mHolder = (ProHolder)view.getTag();
            }
            return view;
        }


        class ProHolder{

        }
    }
}
